<?php
class Req_sfsVideoGames {
	const url = "http://127.0.0.1:38897/videogame/lobbyHandler";
	static function http_post_data($url, $data_string) {
		$ch = curl_init ( $url );
		curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
		curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data_string );
		curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
		curl_setopt ( $ch, CURLOPT_TIMEOUT, 5 );
		curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (
				'Content-Type: application/json',
				'Content-Length: ' . strlen ( $data_string ) 
		) );
		$data = curl_exec ( $ch );
		return $data;
	}
	
	private $m_RoomId;
	
	public function  __construct($roomId){
		$this->m_RoomId = $roomId;
	}
	
	/**
	 * 用户上下分通知
	 *
	 * @return mixed
	 */
	function UserTopUp($name, $coin) {
		$arr = array (
				'req' => '1',
				'1' => $name,
				'2' => $coin,
				'3' => $this->m_RoomId,
		);
		$json_string = json_encode ( $arr );
		return Req_sfsMPZZ2::http_post_data ( Req_sfsVideoGames::url, $json_string );
	}
}
